package com.redhat.redwork.widget.tree;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class TreeServiceImpl implements TreeService {
	
	@Autowired
	protected ApplicationContext applicationContext;

	@Override
	public <T extends TreeNode> List<T> loadTreeNodeData(Class<T> clazz,String modelName,String id,String href) throws Exception {
		if(modelName == null){
			throw new IllegalArgumentException(modelName+ "no defined");
		}
		TreeModel dataModel = (TreeModel)applicationContext.getBean(modelName);
		
		return dataModel.loadData(clazz,id,href);
		
	}

}
